<?php
/** $Id: default_form.php 11917 2009-05-29 19:37:05Z ian $ */
	defined( '_JEXEC' ) or die( 'Restricted access' );
	$session = JFactory::getSession();
	$app = JFactory::getApplication();
	$template = JURI::base() . 'templates/' . $app->getTemplate();
	$user		= JFactory::getUser();
	$eventID = JRequest::getVar('eventid');
	
?>
<script type="text/javascript">

jQuery(document).ready(function() {  

  //select all the a tag with name equal to modal
  jQuery('a[name=modal]').click(function(e) {
    //Cancel the link behavior
    e.preventDefault();
	var option = 'com_jobs';
	var view = 'eventdetail';
	var format = 'raw';
	var task = 'viewJob';
	var userid = <?php echo $user->get('id'); ?>;
	var eventID = <?php echo  $eventID; ?>;
	//Get the A tag href attribute
	var id = jQuery(this).attr('href');
    jQuery.ajax({
		url: 'index.php',
		type: 'POST',
		data: {'option':option,'view':view,'format':format,'task':task,'userid':userid,'eventid':eventID},
		success: function(data) {
			var obj = jQuery.parseJSON(data);
			//alert( obj['guests'] );
			if( data==2 ){
				jQuery('#alert').html('Venligst købe mere punkt<br><a href="index.php?option=com_jobs&view=kobopgaver">Køb Opgaver<a/>');
    			jQuery('#backoverlay').show();
    			jQuery('#show_popup').show();
			}
			else{
				// Set span tags value
				//jQuery('#guests').text(obj['guests']);
				//jQuery('#address').text(obj['address']);
				//jQuery('#postcode').text(obj['postcode'] + '\t' + obj['city']);
				//jQuery('#deadline').text(obj['deadline']);
				//jQuery('#phone').text(obj['phone']);
				
				jQuery('#txtViewTitle').html(obj['title']);
				jQuery('#txtViewEvent').html('<span>Antal gæster:</span>&nbsp;'+obj['guests']+'<br><span>Adresse:</span>&nbsp;'+obj['address']+'<br><span>Post/ By:</span>&nbsp;'+obj['postcode']+'<br><span>Dato &amp; tidspunkt:</span>&nbsp;'+obj['deadline']+'&nbsp;,'+obj['start_hour']+':'+obj['start_minute']
				+'<br><span>Telefon:</span>&nbsp;'+obj['phone']
				+'<br><span>Email:</span>&nbsp;'+obj['email']
				+'<br><span>Tilbud ønskes på:</span>&nbsp;'+obj['offer']
				+'<br>'+obj['data']
				+'');
				
				jQuery('.img-map').html('<iframe width="368" scrolling="no" height="237" frameborder="0" src="https://maps.google.com/maps?q='+obj['address']+' '+ obj['postcode'] + ' ' + obj['city'] + ' Denmark&hnear=' + obj['postcode'] + ' ' + obj['city'] + ' Denmark&amp;t=h&amp;ie=UTF8&amp;hl=en&amp;geocode=FSx4VQMdiHW7AA&amp;split=0&amp;hq=&amp;z=14&amp;iwloc=A&amp;output=embed" marginwidth="0" marginheight="0"></iframe>');
				
				//Show modal popup
				var maskHeight = jQuery(document).height();
				var maskWidth = jQuery(window).width();
			  
				//Set heigth and width to mask to fill up the whole screen
				jQuery('#mask').css({'width':maskWidth,'height':maskHeight});
				
				//transition effect   
				jQuery('#mask').fadeIn(1000);  
				jQuery('#mask').fadeTo("slow",0.8);  
			  
				//Get the window height and width
				var winH = jQuery(window).height();
				var winW = jQuery(window).width();
						  
				//Set the popup window to center
				jQuery(id).css('top',  winH/2-jQuery(id).height()/2);
				jQuery(id).css('left', winW/2-jQuery(id).width()/2);
			  
				//transition effect
				jQuery(id).fadeIn(2000); 
				
			}
		}
	});	
  });
  
  //if close button is clicked
  jQuery('.window .close').click(function (e) {
    //Cancel the link behavior
    e.preventDefault();
    
    jQuery('#mask').hide();
    jQuery('.window').hide();
  });   
  
  //if mask is clicked
  jQuery('#mask').click(function () {
    jQuery(this).hide();
    jQuery('.window').hide();
  });
   
jQuery('.btn-luk').click(function () {
		
		jQuery('#mask').hide();
		jQuery('.window').hide();
  });
  jQuery(window).resize(function () {
   
    var box = jQuery('#boxes .window');
 
        //Get the screen height and width
        var maskHeight = jQuery(document).height();
        var maskWidth = jQuery(window).width();
      
        //Set height and width to mask to fill up the whole screen
        jQuery('#mask').css({'width':maskWidth,'height':maskHeight});
               
        //Get the window height and width
        var winH = jQuery(window).height();
        var winW = jQuery(window).width();

        //Set the popup window to center
        box.css('top',  winH/2 - box.height()/2);
        box.css('left', winW/2 - box.width()/2);
   
  });
  
});

</script>
<div id="boxes">
<div id="dialog1" class="window" style="top: -19px; left: 606px; display: none;">
  <h1 id="txtViewTitle"></h1>
  <p id="txtViewEvent"></p>
   <div class="img-map"></div><!--img-map-->
   <div class="btn-luk"><a href="#">LUK</a></div><!--.bnt-luk-->
</div>
<!--.window-->
 <div id="mask" style="width: 1583px; height: 1298px; display: none; opacity: 0.8;"></div>
</div>
<!--#boxes-->


<div id="header">
  <div id="w-header">
    <div class="logo"><a href="index.php">Forside</a> </div>
    <!--.logo-->
     {module login menu}    
    <!--.nav-top-1-->
    <div class="clear"></div>
    <div class="main-nav">
      {module main menu}
    </div>
    <!--.main-nav-->
    <div class="clear"></div>
  </div>
  <!--#w-header--> 
</div>
<!--#header-->

<div id="main">
  <div id="w-main">
      <div id="main-left">
	<div class="left-find"></div>
	<div class="right-find"></div>
		<div class="find">
			{module search}
		</div> 
      <!--.find-->
      <div class="clear"></div>
      <div class="infomation">
		<?php $article = JUtility::getArticle(15); ?>
        <h2><a href="#"><?php echo $article->title; ?></a></h2>
        <?php echo $article->introtext; ?>
      </div>
      <!--.infomation--> 
    </div>
    <!--#main-left-->
    <div id="main-right2">
      <div id="indhold-caterer-page">
        <div class="icaterer-content">
          <div class="title2">
            <ul>
              <li class="icon-none"><a href="#">Ordrer</a></li>
              <li><a href="#"><?php echo JHTML::_('string.truncate', ($this->item->title), 45); ?></a></li>
            </ul>
          </div>
          <!--title2-->
          <div class="icaterer-content-info">
            <div class="num-guests"> <img src="<?php echo $template; ?>/images/icon-people.png" width="18" height="18" alt="">
              <p>Antal gæster: <span><?php echo $this->item->guests; ?></span></p>
            </div>
            <!--.num-guests-->
            <div class="address-info"> <img src="<?php echo $template; ?>/images/icon-home.png" width="18" height="18" alt="">
              <p><span><?php echo JHTML::_('string.truncate', ($this->item->address), 17); ?></span></p>
            </div>
            <!--.address-info-->
            <div class="timer"> <img src="<?php echo $template; ?>/images/icon-timer.png" width="18" height="18" alt="">
              <p><span><?php  echo JFactory::getDate($this->item->deadline)->toFormat('%d-%m-%Y'); ?></span></p>
            </div>
            <!--.timer-->
			<?php if (in_array(9,$user->get('groups'))) : ?>
				<div class="bnt-looks"><a href="#dialog1" name="modal">SER&gt;&gt;&gt;</a></div>
			<?php elseif(in_array(2,$user->get('groups')) && !empty($this->item_user)  && !empty($this->allUsers)): ?>	
				<div class="caterer3"> <img width="17" height="16" alt="" src="<?php echo $template; ?>/images/icon-3caterer.png">
				  <p><span><a href="<?php echo JRoute::_('index.php?option=com_jobs&view=indholdviewcaterer&eventid='.$this->item->id);?>">der <?php echo count($this->allUsers);?> caterer</a></span></p>
				</div>
			<?php endif; ?>	
            <!--.bnt-looks--> 
          </div>
          <!--.icaterer-content-info-->
          <div class="icaterer-content-main">
            <h1><?php echo $this->item->title; ?></h1>
            <p><?php echo $this->item->description; ?></p>
            
          </div>
          <!--icaterer-content-main-->
          
          <?php if(!empty($this->item_user)) { 
		  		
		  ?>
          <div class="info-map">
          
            <div class="info-map-left">
              <p>Antal gæster: <span><?php echo $this->item_user->guests; ?></span></p>
              <p>Adresse: <span><?php echo $this->item_user->address; ?></span></p>
              <p>Post/ By: <span><?php echo $this->item_user->postcode; ?> <?php echo $this->item_user->city; ?></span></p>
              <p>Dato &amp; tidspunkt: <span><?php  echo JFactory::getDate($this->item_user->deadline)->toFormat('%d-%m-%Y'); ?></span></p>
              <p>Telefon: <span><?php echo $this->userinfo->phone; ?></span></p>
              <div class="line1"></div>
              <!--.line1-->
              <div class="bnt-edit"> <a href="<?php echo JRoute::_('index.php?option=com_jobs&view=tilmelding&task=edit&id='.$this->item->id);?>">rediger</a> </div>
              <!--bnt-edit--> 
            </div>
            <!--.info-map-left-->
            
            <div class="info-map-right"> <iframe width="368" scrolling="no" height="237" frameborder="0" src="https://maps.google.com/maps?q=<?php echo $this->item_user->address; ?> <?php echo $this->item_user->postcode; ?> <?php echo $this->item_user->city; ?> Denmark&hnear= <?php echo $this->item_user->postcode; ?> <?php echo $this->item_user->city; ?> Denmark&amp;t=h&amp;ie=UTF8&amp;hl=en&amp;geocode=FSx4VQMdiHW7AA&amp;split=0&amp;hq=&amp;z=14&amp;iwloc=A&amp;output=embed" marginwidth="0" marginheight="0"></iframe>
			</div>
            <!--.info-map-right--> 
          </div>
          <?php } ?>
           
        </div>
        <!--.icaterer-content--> 
      </div>
      <!--#get-offer-detail-page--> 
    </div>
    <!--#main-right--> 
  </div>
  <!--#w-main--> 
</div>
<!--#main-->
<div class="clear"></div>
<div id="contact">
  <div id="w-contact">
    <div class="left-con">
      <div class="left-con-top"></div>
      <!--left-con-top-->
      <div class="left-con-mid">
        <div class="contact-con">
		<?php $article = JUtility::getArticle(17); ?>
          <h2><a href="#"><?php echo $article->title; ?></a></h2>
          <?php echo $article->introtext; ?>
        </div>
        <!--.contact-con-->
        <div class="contact-con contact-con2">
			<?php $article = JUtility::getArticle(18); ?>
			<h2><a href="#"><?php echo $article->title; ?></a></h2>
			<?php echo $article->introtext; ?>
        </div>
        <!--.contact-con--> 
      </div>
      <!--left-con-mid-->
      <div class="left-con-bottom"></div>
      <!--left-con-bottom--> 
    </div>
    <!--.left-con-->
    
    <div class="address">
		<?php $article = JUtility::getArticle(16); ?>
		<h2><?php echo $article->title; ?></h2>
		<?php echo $article->introtext; ?>
    </div>
    <!--address--> 
    
    <div class="contact-form">
		{module kontakt}
    </div><!--.contact-form-->
  </div>
  <!--w-contact--> 
</div>
<!--#contact-->
<div class="clear"></div>
<div id="copyright">
	<div id="w-copyright">
		{module footer}
	</div>
</div>
<!--#copyright-->